package com.demo.steammanagement.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.demo.steammanagement.service.IRentalsService;
import com.demo.steammanagement.service.IUsersService;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class ScheduledTaskManagerBean {
	
    @Autowired
    private IUsersService usersService;
    
    @Autowired
    private IRentalsService rentalService;

    @Scheduled(cron = "0 0/1 * * * ?")
    public void updateStatus() {
        log.info("更新过期账号状态");
        rentalService.updateExpiredRentals();
    }
    
	@Scheduled(cron = "30 * * * * *")
    public void updateAccountExpirationDate() {
		log.info("更新会员时间");
		usersService.updateAccountExpirationDate();
    }
}
